package dkbta.util.time;

import java.util.Calendar;

/**
 * An enum representing the time units the KBTA can work with.
 * 
 * @author Uri Kanonov
 */
public enum TimeUnit{
	MILLISECOND("Millisecond", Calendar.MILLISECOND, 1),
	SECOND("Second", Calendar.SECOND, 1000),
	MINUTE("Minute", Calendar.MINUTE, 1000 * 60),
	HOUR("Hour", Calendar.HOUR, 1000 * 60 * 60),
	DAY("Day", Calendar.DAY_OF_MONTH, 1000 * 60 * 60 * 24),
	MONTH("Month", Calendar.MONTH, 1000 * 60 * 60 * 30),
	YEAR("Year", Calendar.YEAR, 1000 * 60 * 60 * 365),
	WEEK("Week", Calendar.WEEK_OF_MONTH, 1000 * 60 * 60 * 24 * 7);

	/** The corresponding Calendar class time unit constant */
	public final int calendarTimeUnit;

	/** How many milliseconds there are in one such time unit */
	public final int inMillis;

	private final String _toString;

	/**
	 * Initializes the time unit
	 * 
	 * @param toString String representation of the time unit
	 * @param calendarTimeUnit The corresponding Calendar class time unit constant
	 * @param inMillis How many milliseconds there are in one such time unit
	 */
	TimeUnit(String toString, int calendarTimeUnit, int inMillis){
		this._toString = toString;
		this.calendarTimeUnit = calendarTimeUnit;
		this.inMillis = inMillis;
	}
	
	@Override
	public String toString(){
		return _toString;
	}
}
